const baseUrl = getApp().globalData.domain
Page({
  data:{
    uploadImage:''
  },
  chooseImage(){
    wx.chooseImage({  
      count: 1, // 可选择图片的数量  
      sizeType: ['original', 'compressed'], // 可选择图片的类型：原图或压缩图  
      sourceType: ['album', 'camera'], // 可选择图片的来源：相册或相机  
      success: (res) => {  
        const tempFilePaths = res.tempFilePaths;  
        this.setData({  
          uploadImage: tempFilePaths[0]  
        });  
        console.log(tempFilePaths[0])
      }  
    });  
  },
  uploadImage(){
    const that = this
    wx.request({
      url: baseUrl + '/api/ad/add',
      method:'POST',
      header:{
        'content-type':'application/json',
        token:wx.getStorageSync('token')
      },
      data:{
        "content": "信息技术协会招新",
        "endTime": Date.now(),
        "startTime": Date.now(),
        "title": "信息技术协会招新",
        "url": that.data.uploadImage
      },
      success:(res)=>{
        console.log(res.data)
      }
    })
  },
  getList(){
    wx.request({
      url: baseUrl + '/api/ad/list/page',
      method:'POST',
      header:{
        'content-type':'application/json',
        token:wx.getStorageSync('token')
      },
      data:{
        "current": 1,
        "pageSize": 10,
      },
      success:res=>{
        console.log(res.data)
      }
    })
  }
})